﻿
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.Enum;
using TodoApp.GoodsModel;
using TodoApp.TodoLiveShopCategorysDTO;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;


namespace TodoApp
{
    /// <summary>
    ///  商品分类表 统一规范 实现应用服务接口 
    /// </summary>
    public class LiveShopCategorysSetvice : ApplicationService, ICategorysSetvice
    {
        /// <summary>
        ///  注入 
        /// </summary>
        private readonly IRepository<LiveShopCategorys,int> _Categorys;

        public LiveShopCategorysSetvice(IRepository<LiveShopCategorys, int> Categorys) {
            _Categorys = Categorys;
        }


        /// <summary>
        ///  删除 
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>

        [HttpDelete]
        public async Task DelegateAsync(int Id)
        {
            await _Categorys.DeleteAsync(Id);
        }

        /// <summary>
        ///  添加 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<ShopStatus> InsertAsync(LiveShopCategorysAddDTO model)
        {
             await  _Categorys.InsertAsync(ObjectMapper.Map<LiveShopCategorysAddDTO, LiveShopCategorys>(model));

            return ShopStatus.Succeed;
        }

        /// <summary>
        ///  显示 
        /// </summary>
        /// <returns></returns>
       
        [HttpGet]
        public async  Task<List<LiveShopCategorysShowDTO>> SelectAsync()
        {         
            var str = await _Categorys.GetListAsync();
            return ObjectMapper.Map<List<LiveShopCategorys>, List<LiveShopCategorysShowDTO>>(str);
        }
    }
}
